<?php
namespace Common\Model;
use Think\Model;
class CustPermissionModel extends Model {
	protected $connection = 'DB_BASE_DSN';
	protected $tableName = 'qyx_cust_permission'; 
	
	public function getCustPermissions($custid){
		$result = $this->where(array('custid'=>$custid))->select();
		$tmp = array();
		if(!empty($result)){
			foreach($result as $ret){
				$tmp[] = $ret['permissionid'];
			}
		}
		
		return $tmp;
	}
	
	public function getCustPermission($custid , $permissionid){
		$result = $this->where(array('custid'=>$custid,'permissionid'=>$permissionid))->find();
		return $result;
	}
	
	public function setCustPermissions($custid , $permissionid){
		$data['custid'] = $custid;
		$data['permissionid'] = $permissionid;
		$result = $this->where()->add($data);
		return $result;
	}
	
	
	public function delCustPermissions($custid){
		$result = $this->where(array('custid'=>$custid))->delete();
		return $result;
	}
}



